<?php

namespace WsdServer\Lib\Session;

use Illuminate\Support\Manager;

class SessionManager extends Manager
{
    /**
     * Create an instance of the "cookie" session driver.
     *
     * @return \Illuminate\Session\Store
     */
    protected function createRedisDriver()
    {
        //session 默认过期时间一周
        $ttl = $this->app->config->get('session.ttl', 604800);
        $handler = new RedisSessionHandler($ttl);

        return $this->buildSession($handler);
    }

    /**
     * Build the session instance.
     *
     * @param  \SessionHandlerInterface  $handler
     * @return \WsdServer\Lib\Session\Store
     */
    protected function buildSession($handler)
    {
        return new Store($handler);
    }

    public function getDefaultDriver()
    {
        return $this->app->config->get('session.driver');
    }
}